package com.base.vistter.iframe.inverter.controller;

import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.SysNotice;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.SysNoticeService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/notice")
public class SysNoticeController {

    @Resource(name = "sysNoticeService")
    private SysNoticeService sysNoticeService;

    /**
     * 最新一条通知
     * @return
     * @throws IframeException
     */
    @GetMapping("/latest")
    public Result<SysNotice> latest() throws IframeException {
        return Result.ok(sysNoticeService.latest());
    }

    @GetMapping("/info/{id}")
    public Result<SysNotice> get(@PathVariable("id") Integer id) throws IframeException {
        return Result.ok(sysNoticeService.getSysNoticeById(id));
    }

}
